package com.xxxx.server.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xxxx.server.mapper.SdakaMapper;
import com.xxxx.server.pojo.*;
import com.xxxx.server.service.ISdakaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 学生打卡表 服务实现类
 * </p>
 *
 * @author zhoubin
 * @since 2022-06-01
 */
@Service
public class SdakaServiceImpl extends ServiceImpl<SdakaMapper, Sdaka> implements ISdakaService {

    @Autowired
    private SdakaMapper sdakaMapper;

    @Override
    public List<Sdaka> getSdakaBySDid() {
        return sdakaMapper.getSdakaBySDid(((Admin) SecurityContextHolder.getContext().getAuthentication().getPrincipal()).getId());
    }

    @Override
    public RespPageBean getSdakaByPage(Integer currentPage, Integer size, Sdaka sdaka, String[] beginDateScope) {
        Page<Sdaka> page = new Page<>(currentPage,size);
        IPage<Sdaka> SdakaByPage = sdakaMapper.getSdakaByPage(page, sdaka, beginDateScope);
        RespPageBean respPageBean = new RespPageBean(SdakaByPage.getTotal(), SdakaByPage.getRecords());
        return respPageBean;
    }


    @Override
    public List<Sdaka> getSdaka(Integer id) {
        return sdakaMapper.getSdaka(id);
    }

    @Override
    public List<Map<Object,Object>> getAllDaka(String sdate, String edate) {

        return sdakaMapper.getAllDaka( sdate, edate);

    }

    @Override
    public List<Map<Object, Object>> getalldakaByCl(String sdate, String edate, int collegeid) {
        return sdakaMapper.getalldakaByCl(sdate,edate,collegeid);
    }


}
